package inits

import (
	"flag"
	"gateway/basic/config"
	"log"

	__ "gateway/basic/proto"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func InitGrpc() {
	//address := "14.103.175.165:8500"
	//consulClient, err := untils.NewConsulClient(address)
	//if err != nil {
	//	panic(err)
	//}
	//
	//cfg := untils.GRPC{
	//	Name:    "service",
	//	Tags:    []string{"service"},
	//	Address: "127.0.0.1",
	//	Port:    50051,
	//}
	//
	//err = consulClient.RegisterGRPC(&cfg)
	//if err != nil {
	//	panic(err)
	//}

	flag.Parse()
	addr := "127.0.0.1:50051"
	conn, err := grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	config.UserClient = __.NewUserClient(conn)
}
